var div_article_panel='div_'+article+'_panel';
var div_article_panel_container=div_article_panel+'_container';

var ctrl_article='ctrl_'+div_article;
var form_article='form_'+article;
var link_article='article_link';
var a_article_clearall='a_article_clearall';

function article_div_content(){
	$('<div id="'+ctrl_article+'"></div>').html(''+
		'<form id="'+form_article+'" method="post"'+
		' 	action="./jsp/modules/analyze.jsp" >'+
		'<table width="100%"><tr><td width="100%" colspan="2" align="left">'+
		'	<b>add article link(s): <b>'+
		'</td></tr><tr><td align="left">'+
		'	<input name="'+link_article+'" type="text" style="width:300px; ">'+
		'	<input type="submit" value="get article">'+
		'</td</tr>'+
		'</table>'+
		'</form>'+
	'</div>').appendTo('#'+div_article);
	
	$('#'+div_article).append('<br>'+
		'<table height="18"><tr><td width="100" >'+
			'<b>functions: </b><a id="'+a_article_clearall+'">clear all</a>'+
		'</td><td width="350" align="right">'+
			'<img id="article_progress" src="./images/progress.gif" />'+
		'</td></tr></table>');
	
	$('<div id="'+div_article_panel_container+'" class="container_div"></div>')
	.html('<div id="'+div_article_panel+'" class="sub_add_div"></div>')
	.appendTo('#'+div_article);

	$('#'+div_article_panel).droppable({
		accept: function(d){ 
	        if(d.attr("id").indexOf(TYPE_ARTICLE_SLIDE)>=0){
	        	/** only accept article to moveback */
	            return true;
	        }
		},
		drop:function(event,ui){
			var slide_div=ui.draggable.find('div');
			var slide_id=slide_div.attr('id');
			
			if (!(typeof(slide_id)===undefined_obj)){	
				addback_slide_to_panel(current_type,slide_id);
			}
			
		}
	});
	
	$(function(){
		$('#'+form_article).ajaxForm({
		    beforeSend: function() {
		    	$('#article_progress').show('fast');
		    },
		    uploadProgress: function(
		    		event, position, total, percentComplete) {
		    },
			complete: function(xhr) {
				var ret=xhr.responseText.split(splitter);
				if (ret[0] != 1){
					alert('analyzing article failed' + '\n' + ret[1]);
				}else{
					var temp='';
					for (var i=1;i<ret.length;i++){
						temp+=ret[i]+(i<ret.length-1?splitter:'');
					}
					add_slide_to_panel(current_type,temp);
				}
				$('#article_progress').hide('fast');
			}
		});
	});
	

	$('#'+a_article_clearall).click(function(){
		clear_all(current_type);
	});
	
	$('#article_progress').hide();
}
